Function - General rules

This section outlines rules for using ML function in the Pipe Network context.

Languages

FunctionClosed A function calculates a result according to the current value of its inputs. A function has no internal data and is not linked to declared instances. that interact with the Pipe Network start with ML (for example MLAxisRel, MLPrfWriteOScale, or MLMstRel). These function can be used in all four of the 61131-3 PLC languages.

BlockID Inputs

The BlockID input is a DINT ID. It is the second input to a Pipe Network function when using FFLD:

Example of BlockID Inputs

The BlockID input is the first one if programming in Structured Text:

MLGearRatSlp( BlockID (*DINT*) );

This input identifies the block in the Pipe Network that the function interacts with, and if using the graphical Pipe Network Editor the used variable starts with PipeNetwork.xxx (except if it is acting on a CAM profile, in which case the input is named ProfileID and the variable starts with Profiles.xxx).


  • As a general rule, when selecting a Pipe Block as the BlockID for a ML function, choose a Pipe Block with the same type which is in the name of the ML function.
    For example, MLMstxxx functions expect a Master block to be chosen for the BlockID; MLAxisxxx functions need an Axis block to be chosen for the AxisID input; and MLPrfxxx functions need a Profile entered for ProfileID, etc.

Output status

Most Pipe Network function have a default Boolean output labeled either Q or OK:

Example of Output Status

What is the difference between Q and OK?

OK returns true when function successfully executes.

Q output is initially set to 0 until the first time the block is successfully executed in a running program. After this execution, the Q output is set to 1. It remains to 1 until the function does NOT execute successfully. Alternately, after an unsuccessful execution the Q output is set to 0. It remains to 0 until a successful execution resumes

Difference between Q and OK

When Q is set to True?

Some function change the Q output from low to high immediately after it starts executing, but others (including most functions that command motion) wait to change the output until the function has completely finished executing.
You need to check the description for each individual function block to be sure how its Q output is behaving.

Input parameters

The En input parameter, which is used to execute the function, is not edge-triggered. If a function is seen in the PLCClosed "Programmable Logic Controller" A Programmable Logic Controller, PLC, or Programmable Controller is a digital computer used for automation of industrial processes, such as control of machinery on factory assembly lines. Used to synchronize the flow of inputs from (physical) sensors and events with the flow of outputs to actuators and events code and its En input is positive, the function executes. For example, a MLAxisRel command continuously executes relative moves in a program if it is called each program cycle; thus it acts as a Run/Jog command if continually commanded.

Missing input parameters

All inputs to a function must be entered in order for code to compile.

Position versus distance

Position is a value defined within a coordinate system.

DeltaPosition is a relative measure related to technical units. It is the difference between two positions.

Default Block Parameters

The parameters set when initializing a Pipe Network block are used as defaults when calling functions. These parameters can be modified in a program by using specific functions to set these values. But if a value is never set in a program the parameter entered during initialization is used.

For example:

When making a Master relative move (MLMstRel) you input the DeltaPosition, but not the velocity or acceleration. You can set the velocity for the move by using the MLMstWriteSpeed function before calling the relative move. If the speed is not set in the program, the default parameter entered during the initialization (i.e. in the properties dialog box of the Pipe Blocks) is used.

Concept Link IconSee Also